<template>
  <div class="balance">
    <!-- 条查 -->
    <el-row>
  <el-col :span="24"><div class="grid-content bg-purple-dark">
     <el-form :inline="true" :model="formInline" class="demo-form-inline">
  <el-form-item >
    <el-input v-model="formInline.nickName" placeholder="请输入姓名"></el-input>
  </el-form-item>
  
  <el-form-item>
    <el-button type="primary" @click="search()">查询</el-button>
     <el-button type="primary" @click="Reset()">重置</el-button>
     <el-button type="warning" icon="el-icon-download" @click="handleExport()">导出</el-button>
  </el-form-item>
</el-form>
 
    </div>
   
    </el-col>
  </el-row>
     <el-row>
    <!-- 表格 -->
      <el-col :span="20">
        <div class="grid-content bg-purple-light">
             <el-table
                    :data="tableData"
                    border
                    style="width: 100%">
                    <el-table-column
                    prop="tuser.nickName"
                    label="姓名"
                    width="130px">
                    </el-table-column>
                    <el-table-column
                    prop="tposition.deptName"
                    label="部门"
                    width="130px">
                    </el-table-column>
                    <el-table-column
                    prop="id"
                    label="工号">
                    </el-table-column>
                    <el-table-column
                    prop="tposition.positionName"
                    label="职位"
                    width="130px">
                    </el-table-column>
                        <el-table-column
                    prop="tposition.entryTime"
                    label="入职时间"
                    width="130px">
                    </el-table-column> 
                   
                      <el-table-column
                    prop="holiday.holidayType"
                    label="请假类型"
                    width="130px">
                    </el-table-column> 
                  
                      <el-table-column
                    prop="duration"
                    label="请假时间"
                    width="130px">
                    </el-table-column>  
                      <el-table-column label="操作" width="180">
                    <template slot-scope="scope">
                    <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
                        >修改</el-button
                    >
                   
                    </template>
                </el-table-column>
            </el-table>
             <!-- 分页 -->
                    <el-pagination
                      @size-change="handleSizeChange"
                      @current-change="handleCurrentChange"
                      :current-page="pageNum"
                      :page-sizes="[2, 5, 10, 20]"
                      :page-size="pageSize"
                      layout="total, sizes, prev, pager, next, jumper"
                      :total="total"
                    >
                    </el-pagination>
         </div>
        </el-col>
    </el-row>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "balance",
  data() {
    return {
      tableData: [],
      //分页
      pageNum: 1,
      pageSize:5,
      total: 0,
      formInline:{
        nickName:"",
      }
    };
  },
  created() {
    this.search();
  },
  methods: {
    //重置按钮
    Reset(){
this.formInline.nickName=""
this.search();
    },
    //回显跳转页面
    handleEdit(index,row){
  this.$router.push({path:'/updateBalance',query: {id: row.id }})
    },
    /** 导出按钮操作 */
    handleExport() {
      axios({
        url: "http://localhost:8030/auditCenter/exportblance/excel",
        method: "GET",
        responseType: "arraybuffer", // 接收二进制文件流
      }).then((res) => {
        const content = res.data;
        const blob = new Blob([content], { type: "application/octet-stream" });
        const fileName = "export.xlsx";
        if (typeof window.navigator.msSaveBlob !== "undefined") {
          window.navigator.msSaveBlob(blob, fileName);
        } else {
          const fileUrl = window.URL.createObjectURL(blob);
          const a = document.createElement("a");
          a.href = fileUrl;
          a.target = "_blank";
          a.download = fileName;
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
        }
      });
    },

    //条查 分页
    search() {
      axios
        .post(
          "http://localhost:8030/auditCenter/findbalancePagination?pageNum=" +
            this.pageNum +
            "&pageSize=" +
            this.pageSize,this.formInline
        )
        .then((res) => {
          this.tableData = res.data.rows;
          this.total = res.data.total;
        });
    },
    //分页
    handleCurrentChange(val) {
      this.pageNum = val;
      this.search();
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.search();
    },
  },
};
</script>

<style scoped>

</style>